<?php get_instance()->view('common/header');?>
<style type="text/css">
    <!--
    .text-val {
        padding-top: 3px;
        padding-left: 0;
    }

    .text-label {
        color: grey;
        text-align: right;
    }

    .btn-group, .btn-group-vertical {
        display: inline-block;
        position: absolute;
        vertical-align: middle;
    }

    .sale-summary li:first-child {
        border-top: medium none;
    }

    .sale-summary li {
        border-top: 1px solid #eee;
        overflow: hidden;
        padding: 10px 0;
    }

    .sale-summary li .sale-info {
        color: #646464;
        float: left;
        font-size: 14px;
        text-transform: uppercase;
    }

    .sale-summary li .sale-num {
        color: #169ef4;
        float: right;
        font-size: 20px;
        font-weight: 300;
    }

    .description-box img {
        width: 100%;
    }
    -->
</style>
<style type="text/css">
    div .radio-inline:nth-child(2), div .checkbox-inline:nth-child(2) {
        margin-left: 10px;
    }
    div.form-body>.tab-pane{display: none}
    div.form-body>.tab-pane.active{display: block}

    .table-scrollable > .table > thead > tr > th, .table-scrollable > .table > tbody > tr > th, .table-scrollable > .table > tfoot > tr > th, .table-scrollable > .table > thead > tr > td, .table-scrollable > .table > tbody > tr > td, .table-scrollable > .table > tfoot > tr > td{
        word-break:break-all;
    }
    .mar{margin: 0px}
    .edit-six{margin: 0 5px;}
    .add-six{margin-left: 15px;}
    .del-img-btn{position: absolute;top: 0px;right: 20px;}
    .image{width: 100%;max-height: 300px}
    #edui_fixedlayer{z-index: 10100!important;}
</style>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"><?php echo $title.' - '.$info['name']?></h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li class="btn-group"> <a class="btn default ml_5 return" href="<?php echo getUrl('shop/government');?>"><i class="fa fa-chevron-left"></i> 返回</a> </li>
                        <li><i class="fa fa-home"></i><a href="<?php echo getUrl('shop/government');?>">政府办事指南<i class="fa fa-angle-right"></i></a></li>
                        <li><a href="javascript:void(0);"><?php echo $title?></a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-12 profile-info">
                            <div class="row">
                                <div class="col-md-12">
                                    <div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 30px;">
                                        <div class="row">
                                            <div class="col-md-1">
                                                <ul class="list-unstyled profile-nav">
                                                    <li><img src="<?php echo $info['logo']?>" class="img-responsive" alt=""></li>
                                                </ul>
                                            </div>
                                            <div class="col-md-11">
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">政府名称：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['name'];?></div>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">政府电话：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['tel'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">政府地址：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['address'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">GPS：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['latitude'].','.$info['longitude'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">浏览次数：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['read_number'];?></div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="col-md-4 control-label text-label">创建时间：</label>
                                                            <div class="col-md-8 text-val"><?php echo $info['addtime'];?></div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--end col-md-8-->
                    </div>
                    <!--end row-->
                    <div class="tabbable tabbable-custom tabbable-custom-profile">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="#tab_1_1" data-toggle="tab">信息</a></li>
                            <li><a href="#tab_1_2" data-toggle="tab"> 六县 </a></li>
                            <li><a href="#tab_1_3" data-toggle="tab"> 部门 </a></li>
                            <li><a href="#tab_1_4" data-toggle="tab"> 轮播图 </a></li>
                        </ul>
                        <div class="tab-content">
                            <!--信息-->
                            <div class="active tab-pane " id="tab_1_1">
                                <div class="table-responsive">
                                    <div class="table-container">
                                        <div class="table-actions-wrapper"> <span> </span>
                                            <a href="javascript:;" class="btn btn-sm blue add-btn"><i class="fa fa-plus"></i> 新增</a>
                                        </div>
                                        <table class="table table-bordered table-hover" id="datatable_declare_log">
                                            <thead>
                                                <tr role="row" class="heading">
                                                    <th> ID</th>
                                                    <th> 标题</th>
                                                    <th width="200px">添加时间</th>
                                                    <th width="100px">操作</th>
                                                </tr>
                                                <tr>
                                                    <th></th>
                                                    <th><input class="form-control form-filter input-sm" name="title" type="text"></th>
                                                    <th></th>
                                                    <th> <div class="btn-group">
                                                            <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                            <ul role="menu" class="dropdown-menu pull-right">
                                                                <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                            </ul>
                                                        </div>
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                            <!--六县-->
                            <div class="tab-pane" id="tab_1_2">
                                <div class="portlet-body">
                                    <div class="form-horizontal" >
                                        <div class="form-body six-box"></div>
                                    </div>
                                </div>
                                <script type="text/javascript">
                                    getDistrictList();
                                    function getDistrictList() {
                                        l_blockUI();
                                        var commonUrl = '<?php echo getUrl('shop/government/getDistrictList')?>';
                                        var id = '<?php echo $info["id"]?>';
                                        var butEdit = "<?php echo adminAuthority('home-edit', 'question')?>";
                                        var url = "<?php echo getUrl('shop/government/districtEdit?id=')?>"+id;
                                        var addUrl = "<?php echo getUrl('shop/government/districtAdd?id=')?>"+id;
                                        $.ajax(commonUrl, {
                                            dataType: 'json',
                                            type: 'post',
                                            data: {id: id},
                                            error: function () {
                                                show_message({status: 0, message: '请求超时'});
                                                App.unblockUI();
                                            },
                                            timeout: 60000,
                                            success: function (data, textStatus, jqXHR) {
                                                if (data.message) {
                                                    show_message(data);
                                                }

                                                var html = '';
                                                if (!data.length) {
                                                    html = '<div class="well item-box" style="height:200px;text-align:center;padding-top:100px;">没有相关信息！' +
                                                        '<a href="'+addUrl+'" class="btn blue add-six"><i class="fa fa-plus"></i> 新增 </a></div>';
                                                }
                                                $.each(data, function (k, v) {
                                                    if (k == 0) {
                                                        html += '<a class="btn blue add-six" href="'+addUrl+'" style="float: right"><i class="fa fa-plus"></i> 新增 </a>';
                                                    }
                                                    html += '<div class="form-group"><h3 class="form-section">' + v.district_name+
                                                        '<a href="'+url+'&district='+v.id+'" class="btn btn-xs blue-stripe default edit-six"> 编辑</a>' + // edit-six  data-id="'+v.id+'"
                                                        '<a href="javascript:;" class="btn btn-xs red-stripe default delete-six" data-id="'+v.id+'"> 删除</a>';

                                                    $.each(v.address, function (kk, vv) {
                                                        html += '</h3><h4 class="col-md-1">' + vv.type +'</h4>';
                                                        html += '<div class="row col-md-11">';
                                                        $.each(vv.address, function (key, obj) {
                                                            html += '<div class="col-md-6"><div class="form-group">';
                                                            html += '<label class="control-label col-md-3">地址:</label><div class="col-md-9"><p class="form-control-static">' + obj.address + '（GPS:'+obj.lat+','+obj.lng+'）</p>';
                                                            html += '</div></div></div>';
                                                            html += '<div class="col-md-6"><div class="form-group">';
                                                            html += '<label class="control-label col-md-3">电话:</label>';
                                                            html += '<div class="col-md-9"><p class="form-control-static">' + obj.tel + '</p>';
                                                            html += '</div></div></div>';
                                                        });
                                                        html += '<div class="col-md-12" style="border-bottom: 1px solid #e5e5e5;margin: 10px 0;"></div></div>';
                                                    });
                                                    html += '</div>';
                                                });
                                                $('.six-box').html(html);
                                                App.unblockUI();
                                            }
                                        });
                                    }
                                </script>
                            </div>

                            <!--监管部门-->
                            <div class="tab-pane" id="tab_1_3">
                                <form action="<?php echo getUrl('shop/government/saveBranch')?>" class="form-horizontal branch_form" method="post" id="branch-form" novalidate="novalidate">
                                    <div style="float: right;margin-bottom: 10px;">
                                        <a class="btn add-branch" href="javascript:void(0);"><i class="fa fa-plus"></i> 添加</a>
                                        <input name="id" value="<?php echo $info['id'];?>" type="hidden">
                                        <button class="btn green"><i class="fa fa-save"></i> 保存</button>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="branch" style="border: 1px solid #ddd; padding: 10px; margin-bottom: 30px;"></div>
                                        </div>
                                    </div>
                                </form>
                                <script type="text/javascript">
                                    $(function () {
                                        var branch = $(".branch");
                                        // 添加
                                        $(".add-branch").click(function () {
                                            var len = branch.find('.input_branch').length;

                                            if (len > 0) {
                                                var input = branch.find('.input_branch');
                                                var title = input.eq(len-2).val();
                                                var mobile = input.eq(len-1).val();
                                                if (!title.length || !mobile.length) {
                                                    show_message({status: 0, message: '请完成上一个信息的填写'});
                                                    return false;
                                                }
                                            }
                                            var html = '<div class="row branch-box">'+
                                                        '   <div class="col-md-5">'+
                                                        '       <div class="form-group">'+
                                                        '           <label class="col-md-2 control-label text-label">部门名称：</label>'+
                                                        '           <div class="col-md-10">'+
                                                        '               <input class="form-control required input_branch" name="title[]" type="text">'+
                                                        '           </div>'+
                                                        '       </div>'+
                                                        '   </div>'+
                                                        '   <div class="col-md-5">'+
                                                        '       <div class="form-group">'+
                                                        '           <label class="col-md-2 control-label text-label">部门电话：</label>'+
                                                        '           <div class="col-md-10" >'+
                                                        '               <input class="form-control required input_branch" name="mobile[]" type="tel" minlength="7">'+
                                                        '           </div>'+
                                                        '       </div>'+
                                                        '   </div>'+
                                                        '   <div class="col-md-2" style="margin-top: 9px;"><a class="del-branch-btn" href="javascript:void(0);"><i class="fa fa-times"></i></a></div>'+
                                                        '</div>';
                                            if(len == 0){
                                                branch.html(html);
                                            }else{
                                                branch.append(html);
                                            }
                                        });

                                        // 移除
                                        $(".del-branch-btn").live('click',function () {
                                            $(this).parents('.branch-box').remove();
                                            var len = branch.find('.branch-box').length;
                                            if (len == 0){
                                                $('.branch').html('<div class="well item-box" style="height:200px;text-align:center;padding-top:100px;">没有部门相关信息</div>');

                                            }
                                        });

                                        $.e_validate.init('#branch-form',{});

                                        getBranchList();

                                        // 获取数据
                                        function getBranchList() {
                                            l_blockUI();
                                            var commonUrl = '<?php echo getUrl('shop/government/getBranchList')?>';
                                            var id = '<?php echo $info["id"]?>';
                                            $.ajax(commonUrl, {
                                                dataType: 'json',
                                                type: 'post',
                                                data: {id: id},
                                                error: function () {
                                                    show_message({status: 0, message: '请求超时'});
                                                    App.unblockUI();
                                                },
                                                timeout: 60000,
                                                success: function (data, textStatus, jqXHR) {
                                                    if (data.message) {
                                                        show_message(data);
                                                    }

                                                    var html = '';
                                                    if (!data.data.length) {
                                                        html = '<div class="well item-box" style="height:200px;text-align:center;padding-top:100px;">没有部门相关信息</div>';
                                                    }else {
                                                        $.each(data.data, function (k, v) {
                                                            html += '<div class="row branch-box">' +
                                                                '   <div class="col-md-5">' +
                                                                '       <div class="form-group">' +
                                                                '           <label class="col-md-2 control-label text-label">部门名称：</label>' +
                                                                '           <div class="col-md-10">' +
                                                                '               <input class="form-control required input_branch" name="title[]" type="text" value="' + v.title + '">' +
                                                                '           </div>' +
                                                                '       </div>' +
                                                                '   </div>' +
                                                                '   <div class="col-md-5">' +
                                                                '       <div class="form-group">' +
                                                                '           <label class="col-md-2 control-label text-label">部门电话：</label>' +
                                                                '           <div class="col-md-10" >' +
                                                                '               <input class="form-control required input_branch" name="mobile[]" type="tel" minlength="7" value="' + v.mobile + '">' +
                                                                '           </div>' +
                                                                '       </div>' +
                                                                '   </div>' +
                                                                '   <div class="col-md-2" style="margin-top: 9px;"><a class="del-branch-btn" href="javascript:void(0);"><i class="fa fa-times"></i></a></div>' +
                                                                '</div>';
                                                        });
                                                    }
                                                    $('.branch').html(html);
                                                    App.unblockUI();
                                                }
                                            });
                                        }
                                    })
                                </script>
                            </div>

                            <!--轮播图-->
                            <div class="tab-pane" id="tab_1_4">
                                <form action="<?php echo getUrl('shop/government/saveImage')?>" class="form-horizontal" method="post" id="image-form" novalidate="novalidate">
                                    <div style="float: right;margin-top: -10px;">
                                        <div class="upload-img logo-line" style="float: left;">
                                            <div id="uploader-demo" style="margin-top:10px;margin-left: 10px;">
                                                <div id="fileList" class="uploader-list"></div>
                                                <div class="filePicker-pic">添加图片</div>
                                            </div>
                                            <div style="width:100%;height:10px;">
                                                <div id="progress-pic" style="height:100%;width:0;background-color:green;">&nbsp;</div>
                                            </div>
                                        </div>
                                        <input name="id" value="<?php echo $info['id'];?>" type="hidden">
                                        <button class="btn green" style="float: right;margin-top: 10px;height: 38px;margin-left: 10px;"><i class="fa fa-save"></i> 保存</button>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div style="border: 1px solid #ddd; padding: 10px; margin-bottom: 30px;">
                                                <div class="row img-box">
                                                    <?php if (empty($info['pic'])):?>
                                                        <div class="well item-box" style="height:200px;text-align:center;padding-top:100px;">没有相关信息</div>
                                                    <?php else: foreach ($info['pic'] as $k => $v):?>
                                                        <div class="col-md-3 img_div">
                                                            <img src="<?php echo $v?>"  class="image">
                                                            <input name="pic[]" type="hidden" class="img-input-pic" value="<?php echo $v; ?>"/>
                                                            <a class="del-img-btn" href="javascript:void(0);"><i class="fa fa-times"></i></a>
                                                        </div>
                                                    <?php endforeach; endif;?>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                                <script type="text/javascript">
                                    $(function () {
                                        var uploader = WebUploader.create({
                                            auto: true,
                                            server: '<?php echo getUrl('shop/government/uploadImge');?>', // 文件接收服务端
                                            pick: '.filePicker-pic',
                                            // 只允许选择图片文件
                                            accept: {
                                                title: 'Images',
                                                extensions: 'gif,jpg,jpeg,bmp,png',
                                                mimeTypes: 'image/*'
                                            },
                                            fileVal:'Filedata'
                                        });

                                        //文件上传过程中创建进度条实时显示。
                                        uploader.on( 'uploadProgress', function( file, percentage ) {
                                            $('#progress-pic').css( 'width', percentage * 100 + '%' );
                                        });

                                        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                                        uploader.on( 'uploadSuccess', function( file, response) {
                                            $(".img-box").append( '<div class="col-md-3">'+
                                                '   <img src="'+response._raw+'" class="image">'+
                                                '   <input name="pic[]" type="hidden" class="img-input-pic" value="'+response._raw+'"/>'+
                                                '   <a class="del-img-btn" href="javascript:void(0);"><i class="fa fa-times"></i></a>'+
                                                '</div>');
                                        });

                                        // 完成上传完了，成功或者失败，先删除进度条。
                                        uploader.on( 'uploadComplete', function( file ) {
                                            $('#progress-pic').width(0);
                                        });

                                        $(".del-img-btn").live('click',function () {
                                            $(this).parents('.img_div').remove();
                                            if ($(".img_div").length == 0){
                                                $('.img-box').html('<div class="well item-box" style="height:200px;text-align:center;padding-top:100px;">没有相关信息</div>');
                                            }
                                        });

                                        $.e_validate.init('#image-form',{});
                                    });
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--信息-->
<div id="save-modal" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('shop/government/saveDeclareLog'); ?>" class="form-horizontal" id="save-form" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">标题<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input type="text" name="title" class="form-control required"/>
                        </div>
                    </div>
                    <div class="form-group price-box">
                        <div class="col-md-12">
                            <script id="content" name="content" type="text/plain" ></script>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" value=""/>
                    <input type="hidden" name="government_id" value="<?php echo $info['id']?>"/>
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                    <button class="btn green field-submit-btn"><i class="fa fa-save"></i> 保存</button>
                    <script type="text/javascript">
                        $(function(){
                            ue = UE.getEditor('content',{initialFrameWidth:'100%',initialFrameHeight:'350',autoHeightEnabled:false,serverUrl:'<?php echo getUrl('shop/government/editor');?>'});

                            var model = $('#save-modal');
                            $('.add-btn').live('click', function(){
                                model.find('.modal-title').html('新增');
                                model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                model.find('.show_message_error').remove();
                                model.find('.modal-body').find('input').val('');
                                model.find("[name='id']").val('');
                                ue.setContent('');//清空
                                model.modal();
                            });

                            $('.btn-edit').live('click', function(){
                                var id = $(this).attr('data-id');
                                l_blockUI();
                                $.ajax('<?php echo getUrl('shop/government/getDeclareLogInfo')?>', {
                                    dataType:'json',
                                    type:'post',
                                    data:{id:id},
                                    error:function(){
                                        show_message({status:0, message:'请求超时'});
                                        App.unblockUI();
                                    },
                                    timeout:60000,
                                    success:function(data,textStatus,jqXHR){
                                        if(data.status <= 0){
                                            show_message(data);
                                            return;
                                        }
                                        model.find('.modal-title').html('编辑  - '+data.data.title);
                                        model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                        model.find('.show_message_error').remove();
                                        for(var k in data.data){
//                                            if(k == 'status'){
//                                                model.find('[name="'+k+'"]').attr('checked', false);
//                                                model.find('[name="'+k+'"][value="'+data.data[k]+'"]').attr('checked', true);
//                                                model.find('[name="'+k+'"]').uniform();
//                                            }else{
//
//                                            }
                                            model.find('[name="'+k+'"]').val(data.data[k]);
                                        }
                                        ue.setContent(data.data.content);//清空
                                        model.modal();
                                        App.unblockUI();
                                    }
                                });
                                return false;
                            });

                            $.e_validate.init('#save-form',{modal:model,ignore:'',successCallback:function(data){
                                $(".filter-cancel").click();
                            }});

                            $("#edui3_body").live('click',function () {
                                var margin = $(".modal-dialog").css('margin');
                                if (margin == '0px'){
                                    $(".modal-dialog").removeClass('mar');
                                }else{
                                    $("#save-modal").css('position','fixed');
                                    $("#edui1").css('left',0);
                                    $("#edui1").css('top',0);
                                    $(".modal-dialog").addClass('mar');
                                }
                            });

                        });
                    </script>
                </div>
            </form>
        </div>
    </div>
</div>

<!--六县-->
<div id="six-modal" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('shop/government/saveDistrict'); ?>" class="form-horizontal" id="six-form" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">区县名称<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input type="text" name="district_name" class="form-control required"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">类型<span class="required">*</span></label>
                        <div class="col-md-5" style="margin-top: 6px;">
                            <a href="javascript:void(0);" class="add-address-tel" type="1"><i class="fa fa-plus"></i> 添加县局</a>
                        </div>
                        <div class="col-md-5" style="margin-top: 6px;">
                            <a href="javascript:void(0);" class="add-address-tel" type="2"><i class="fa fa-plus"></i> 添加县所</a>
                        </div>
                    </div>
                    <div class="address-tel"></div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" value=""/>
                    <input type="hidden" name="g_id" value="<?php echo $info['id']?>"/>
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                    <button class="btn green field-submit-btn"><i class="fa fa-save"></i> 保存</button>
                    <script type="text/javascript">
                        $(function(){
                            var model = $('#six-modal');

                            /*$('.add-six').live('click', function(){
                                model.find('.modal-title').html('新增');
                                model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                model.find('.show_message_error').remove();
                                model.find('.modal-body').find('input').val('');
                                model.find("[name='id']").val('');
                                model.modal();
                            });*/

                            /* // echo getUrl('shop/government/getDistrictInfo')
                            $('.edit-six').live('click', function(){
                                var id = $(this).attr('data-id');
                                l_blockUI();
                                $.ajax('', {
                                    dataType:'json',
                                    type:'post',
                                    data:{id:id},
                                    error:function(){
                                        show_message({status:0, message:'请求超时'});
                                        App.unblockUI();
                                    },
                                    timeout:60000,
                                    success:function(data,textStatus,jqXHR){
                                        if(data.status <= 0){
                                            show_message(data);
                                            return;
                                        }
                                        model.find('.modal-title').html('编辑  - '+data.data.district_name);
                                        model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                        model.find('.show_message_error').remove();
                                        for(var k in data.data){
                                            if(k == 'address'){
                                                var html = '';
                                                $.each(data.data.address,function (kk, vv) {
                                                    var addressName,telName;
                                                    if (vv.type == '县局'){
                                                        addressName = 'bureau_address[]';
                                                        telName = 'bureau_tel[]';
                                                    }else{
                                                        addressName = 'county_address[]';
                                                        telName = 'county_tel[]';
                                                    }
                                                    $.each(vv.address,function (k, v) {
                                                        html += '<div class="form-group">' +
                                                            '<label class="control-label col-md-2">'+vv.type+'地址&电话<span class="required">*</span></label>' +
                                                            '<div class="col-md-10 input-group" style="padding-left: 15px;">' +
                                                            '<input class="form-control required" name="'+addressName+'"  placeholder="请填写地址" value="' + v.address + '" type="tel">' +
                                                            '<input class="form-control required" name="'+telName+'" placeholder="请填写电话" type="tel" value="' + v.tel + '">' +
                                                            '<span class="input-group-addon delete-six-btn"><a href="javascript:void(0);"><i class="fa fa-times"></i></a></span>' +
                                                            '</div></div>';
                                                    });
                                                });
                                                $(".address-tel").html(html);
                                            }else{
                                                model.find('[name="'+k+'"]').val(data.data[k]);
                                            }
                                        }
                                        model.modal();
                                        App.unblockUI();
                                    }
                                });
                                return false;
                            });*/

                            $(".delete-six").live('click',function () {
                                var id = $(this).attr('data-id');
                                l_blockUI();
                                $.ajax('<?php echo getUrl('shop/government/deleteDistrict')?>', {
                                    dataType:'json',
                                    type:'post',
                                    data:{id:id},
                                    error:function(){
                                        show_message({status:0, message:'请求超时'});
                                        App.unblockUI();
                                    },
                                    timeout:60000,
                                    success:function(data,textStatus,jqXHR){
                                        show_message(data);
                                        if(data.status == 1){
                                            getDistrictList();
                                        }
                                        App.unblockUI();
                                    }
                                });
                                return false;
                            });

                            $.e_validate.init('#six-form',{modal:model,ignore:'',successCallback:function(data){
                                getDistrictList();
                            }});

                            /**
                             * 添加地址&电话
                             */
                            $(".add-address-tel").live('click',function () {
                                var len = $(".address-tel").find('.form-group').length;
                                if (len > 0) {
                                    var gr = $(".address-tel").find('.form-group').eq(len - 1);
                                    var address = gr.find('input').eq(0).val();
                                    var tel = gr.find('input').eq(1).val();
                                    if (!address.length || !tel.length) {
                                        show_modal_message({
                                            error: 0,
                                            message: '请完成上一个信息的填写'
                                        }, model.find('.modal-body'));
                                        return false;
                                    }
                                }
                                var type = $(this).attr('type');
                                var addressName,telName,name;
                                if (type == 1){
                                    addressName = 'bureau_address[]';
                                    telName = 'bureau_tel[]';
                                    name = '县局';
                                }else{
                                    addressName = 'county_address[]';
                                    telName = 'county_tel[]';
                                    name = '县所';
                                }
                                var html = '<div class="form-group">' +
                                        '<label class="control-label col-md-2">'+name+'地址&电话<span class="required">*</span></label>' +
                                        '<div class="col-md-10 input-group" style="padding-left: 15px;">' +
                                            '<input class="form-control required" name="'+addressName+'"  placeholder="请填写地址" type="tel">' +
                                            '<input class="form-control required" name="'+telName+'" placeholder="请填写电话" type="tel">' +
                                            '<span class="input-group-addon delete-six-btn"><a href="javascript:void(0);"><i class="fa fa-times"></i></a></span>' +
                                        '</div></div>';
                                $(".address-tel").append(html)
                            });

                            /**
                             * 删除
                             */
                            $(".delete-six-btn").live('click',function () {
                                $(this).parents('.form-group').remove();
                            });
                        });
                    </script>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    var id = <?php echo $info['id'];?>;
    $(function(){
        datatable_init({
            src: $("#datatable_declare_log"),
            sAjaxSource: "<?php echo getUrl('shop/government/getDeclareLogList?id=');?>"+id,
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,1,3]
            }]
        });

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN'
        });

    });
</script>
</body>
</html>